Page({
  data: {
    swiperList: [
      { id: 1, url: 'https://picsum.photos/750/300?random=1' },
      { id: 2, url: 'https://picsum.photos/750/300?random=2' },
      { id: 2, url: 'https://picsum.photos/750/300?random=3' },
      { id: 3, url: 'https://picsum.photos/750/300?random=4' }
    ],
    cardCur: 0,
    hotList: [
      { id: 1, name: '三体：地球往事', path: 'https://picsum.photos/300/450?random=101', author: '刘慈欣', rate: 9.2 },
      { id: 2, name: '活着', path: 'https://picsum.photos/300/450?random=102', author: '余华', rate: 9.5 },
      { id: 3, name: '百年孤独', path: 'https://picsum.photos/300/450?random=103', author: '马尔克斯', rate: 9.3 },
      { id: 4, name: '追风筝的人', path: 'https://picsum.photos/300/450?random=104', author: '卡勒德', rate: 9.1 },
      { id: 5, name: '人类简史', path: 'https://picsum.photos/300/450?random=105', author: '尤瓦尔', rate: 9.0 },
      { id: 6, name: '解忧杂货店', path: 'https://picsum.photos/300/450?random=106', author: '东野圭吾', rate: 8.9 },
      { id: 7, name: '小王子', path: 'https://picsum.photos/300/450?random=107', author: '圣埃克苏佩里', rate: 9.4 },
      { id: 8, name: '月亮与六便士', path: 'https://picsum.photos/300/450?random=108', author: '毛姆', rate: 8.8 }
    ]
  },

  // 轮播图切换
  cardSwiper(e) {
    this.setData({ cardCur: e.detail.current });
  },

  // 跳转分类页
  goCategory(e) {
    wx.switchTab({ url: `/pages/category/index` });
  },

  // 查看书籍详情
  handelLook(e) {
    const {item} = e.currentTarget.dataset;
    // 将书籍数据存储到本地缓存
    wx.setStorageSync('Bookinfo', item);
    wx.navigateTo({ url: '/pages/bookinfo/index' });
  }
})